package Classes.Objects.Personagens 
{
	import Box2D.Common.Math.b2Vec2;
	import Classes.core.World;
	import Classes.Objects.PhysicsObject;
	import Classes.Utils.Input;
	import flash.ui.Keyboard;
	/**
	 * ...
	 * @author ...
	 */
	public class Indio extends PhysicsObject
	{
		[Property(value = "0")]
		public var lala:Number = 0;
		
		private var desiredFriction: Number;
		public static var orientacao:Boolean = true
		
		public function Indio(world: World, isStatic:Boolean, x: Number, y: Number, width: Number, height: Number, artName: String,rotation:Number) 
		{
			super(world, isStatic, x, y, width, height, artName, rotation);
			
			desiredFriction = this.body.GetFixtureList().GetFriction();
		}
		
		public override function update():void
		{
			if (Input.isTriggered(Keyboard.W))
			{
				this.body.GetLinearVelocity().Add(new b2Vec2(0, -11));
			}
			
			if (Input.isPressed(Keyboard.A))
			{
				this.body.GetLinearVelocity().Add(new b2Vec2(-0.3, 0));
				this.body.GetFixtureList().SetFriction(0);
				orientacao = false;
				
				if (art.scaleX > 0)
					art.scaleX *= -1
			}
						
			if (Input.isPressed(Keyboard.D))
			{
				this.body.GetLinearVelocity().Add(new b2Vec2(0.3, 0));
				this.body.GetFixtureList().SetFriction(0);
				orientacao = true;
				
				if (art.scaleX < 0)
					art.scaleX *= -1
			}
			
			if (Input.isPressed(Keyboard.V))
			{
				visible = !visible;
			}
			
			if ((!Input.isDown(Keyboard.D)) && (!Input.isDown(Keyboard.A))) 
			{
				this.body.GetFixtureList().SetFriction(desiredFriction);
			}
			super.update();
		}
		
	}

}